<?php
ini_set('error_reporting',E_ALL|E_STRICT);
ini_set('display_errors',true);

require('../lib/SocuteTemplate.php');

$tpl2 = new SocuteTemplate('sample02_inserted.tpl');
$tpl2->dispatch($tpl2->makeSection('customSeparator'));

$tpl1 = new SocuteTemplate('sample02.html');
$tpl1->set('title', 'Hello World from SoCuTE');

$header = $tpl1->makeSection('header');
$row1 = $tpl1->makeSection('row');
$userWithInfo1 = $tpl1->makeSection('userWithInfo');
$userWithInfo1->set('name','Agus');
$userWithInfo1->set('dob','1990-01-01');
$userWithInfo1->set('gender','male');
$userWithInfo1->set('city','Jakarta');

$userWithInfo2 = $tpl1->makeSection('userWithInfo');
$userWithInfo2->set('name','Rihana');
$userWithInfo2->set('dob','1992-12-12');
$userWithInfo2->set('gender','female');
$userWithInfo2->set('city','Bandung');

$row1->set('customSeparator', $tpl2);

$row2 = $tpl1->makeSection('row');
$userWithoutInfo = $tpl1->makeSection('userWithoutInfo');
$userWithoutInfo->set('name','John');

$row2->set('customSeparator', $tpl2);

// dispatching sections
$tpl1->dispatch($header);
$tpl1->dispatch($row1);
  $row1->dispatch($userWithInfo1);
  $row1->dispatch($userWithInfo2);
$tpl1->dispatch($row2);
  $row2->dispatch($userWithoutInfo);
  
// redispatching example
$tpl1->dispatch($row1); // for example only, i don't know why you would do this (redispatching the same section object) line in real world
$userWithInfo1->set('city', 'Malang'); // because it still refer to one object, it should work as expected

$tpl1->render();
?>
